package br.com.javajsf.connection;

import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class ConnectionFactory {
	
	public static Connection getConnection() {
        try {
            InitialContext initialContext = new InitialContext();
            DataSource dataSource = (DataSource) initialContext.lookup("jdbc/cantina");
            return dataSource.getConnection();
            //fadsfsad
        } catch (NamingException ex) {
            //Logger.getLogger(ConnectionFactory.class.getName()).log(Level.SEVERE, null, ex);
        	ex.printStackTrace();
        	System.out.println(ex.getMessage());
        } catch (SQLException ex) {
        	ex.printStackTrace();
        	System.out.println(ex.getMessage());
            //Logger.getLogger(ConnectionFactory.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

}
